import threading, queue

import time


def work(a):
    while not q.empty():
        item = q.get()
        print(a, '-----------')
        print(threading.current_thread())
        print('------------')
        time.sleep(1)


def run():
    threads = []
    for i in range(20):
        q.put(i)
    for i in range(1, 11):  # 开启10个线程
        t = threading.Thread(target=work, args=(i,))
        t.start()
        threads.append(t)
    for t in threads:
        t.join()

if __name__ == '__main__':
    q = queue.Queue()
    run()